import { Table } from 'antd';
import React from 'react';
import InnovationStudioController from '../../../services/InnovationStudio/InnovationStudioController'

class Test extends React.Component {
    constructor(props) {
        super(props);
        let userInfo = JSON.parse(sessionStorage.getItem('userInfo'))
        this.state = { 
            userInfo:userInfo,
            dataSource:[],
            dataList:[1,2,3,4]
         };
    }
    componentDidMount(){
        let {userInfo} = this.state
        InnovationStudioController.getMembersPage({userName : userInfo.userName}).then(r=>{
            this.setState({
                dataSource:r.data.rows
            })
        })
    }
    up=(index)=>{
        let {dataList} = this.state
        let current = dataList[index]
        let target = dataList[index-1]
        dataList[index]=target
        dataList[index-1]=current
        this.setState({dataList})
        console.log(index)
    }
    down=(index)=>{
        let {dataList} = this.state
        let current = dataList[index]
        let target = dataList[index+1]
        dataList[index]=target
        dataList[index+1]=current
        this.setState({dataList})
        console.log(index)
    }
    render() {
        let {dataSource,dataList} = this.state
        const columns=[
            {title:'工作室名称',dataIndex:'studioName',align:'center'},
            // {title:'申请人',dataIndex:'name',align:'center'},
            {title:'加入时间',dataIndex:'createdAt',align:'center'},
            {title:'是否为领导',dataIndex:'isLeader',align:'center',render:text=>text==='是'?'是':'否'},
            {title:'审批状态',dataIndex:'reviewStatus',align:'center'},
            {title:'审批人',dataIndex:'reviewName',align:'center'},
            {title:'审批时间',dataIndex:'reviewTime',align:'center'},
            {title:'审批备注',dataIndex:'reviewRemark',align:'center'},
        ]
        return (
            <div>
                {dataList.map((item,index)=>{
                    return<h1 key={index} >{item}<text onClick={this.up.bind(this,index)}>上</text><text onClick={this.down.bind(this,index)}>下</text></h1>
                })}
                
                <Table dataSource={dataSource} columns={columns}/>
            </div>
        );
    }
}

export default Test;